package com.service.impl;

import com.bean.Admin;
import com.bean.Owner;
import com.dao.LoginDAO;
import com.dao.impl.LoginDAOImpl;
import com.service.LoginService;

import java.sql.SQLException;

public class LoginServiceImpl implements LoginService {
    private LoginDAO loginDAO = new LoginDAOImpl();
    @Override
    public Admin login(String name, String password) throws SQLException {
        Admin admin = loginDAO.Login(name);
        if(admin!=null){
            if (admin.getAdminPassword().equals(password)){
                return admin;
            }
            return null;
        }
        return null;
    }

    @Override
    public Owner login1(String id, String password) throws SQLException {
        Owner owner = loginDAO.Login1(id);
        if (owner != null){
            if (owner.getOwnerPassword().equals(password)){
                return owner;
            }
            return null;
        }
        return null;
    }
}
